package io;

import java.io.*;

public class Demo12 {
    public static void main(String[] args) {
        try (OutputStream outputStream = new FileOutputStream("d:/test.txt")){
            // 这就相当于把字节流转换为字符流
            PrintWriter writer = new PrintWriter(outputStream);
            writer.println("hello");
            // 刷新（冲刷）缓冲区 确保数据被写入硬盘
            writer.flush();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
